package com.itheima.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.time.LocalDateTime;
import java.util.Date;

import lombok.Data;

/**
 * 操作日志表
 *
 * @TableName operate_log
 */
@TableName(value = "operate_log")
@Data
public class OperateLog {
    /**
     * ID
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 操作人ID
     */
    private Integer operateEmpId;

    /**
     * 操作时间
     */
    private LocalDateTime operateTime;

    /**
     * 操作的类名
     */
    private String className;

    /**
     * 操作的方法名
     */
    private String methodName;

    /**
     * 方法参数
     */
    private String methodParams;

    /**
     * 返回值
     */
    private String returnValue;

    /**
     * 方法执行耗时, 单位:ms
     */
    private Long costTime;


    //封装操作人员的名字
    private String operateEmpName;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        OperateLog other = (OperateLog) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
                && (this.getOperateEmpId() == null ? other.getOperateEmpId() == null : this.getOperateEmpId().equals(other.getOperateEmpId()))
                && (this.getOperateTime() == null ? other.getOperateTime() == null : this.getOperateTime().equals(other.getOperateTime()))
                && (this.getClassName() == null ? other.getClassName() == null : this.getClassName().equals(other.getClassName()))
                && (this.getMethodName() == null ? other.getMethodName() == null : this.getMethodName().equals(other.getMethodName()))
                && (this.getMethodParams() == null ? other.getMethodParams() == null : this.getMethodParams().equals(other.getMethodParams()))
                && (this.getReturnValue() == null ? other.getReturnValue() == null : this.getReturnValue().equals(other.getReturnValue()))
                && (this.getCostTime() == null ? other.getCostTime() == null : this.getCostTime().equals(other.getCostTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getOperateEmpId() == null) ? 0 : getOperateEmpId().hashCode());
        result = prime * result + ((getOperateTime() == null) ? 0 : getOperateTime().hashCode());
        result = prime * result + ((getClassName() == null) ? 0 : getClassName().hashCode());
        result = prime * result + ((getMethodName() == null) ? 0 : getMethodName().hashCode());
        result = prime * result + ((getMethodParams() == null) ? 0 : getMethodParams().hashCode());
        result = prime * result + ((getReturnValue() == null) ? 0 : getReturnValue().hashCode());
        result = prime * result + ((getCostTime() == null) ? 0 : getCostTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", operateEmpId=").append(operateEmpId);
        sb.append(", operateTime=").append(operateTime);
        sb.append(", className=").append(className);
        sb.append(", methodName=").append(methodName);
        sb.append(", methodParams=").append(methodParams);
        sb.append(", returnValue=").append(returnValue);
        sb.append(", costTime=").append(costTime);
        sb.append("]");
        return sb.toString();
    }
}